<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/
  defined('_JEXEC') or die('Retricted Access');
  global $option;
  global $jbconfig;
  $items = $this->items;
  $arr_status_invoice = JobBoardConstant::getStatus_Invoice();
  $pagination = $this->pagination;
  $user_id = JRequest::getVar('userid');
  $lists = $this->lists;
?>

<script language="javascript" type="text/javascript">
function submitbutton(pressbutton) {
	var form = document.adminForm;
	form.task.value=pressbutton;
	form.submit();
}
</script>
<form action="index.php" method="post" name="adminForm" class="content-right">
<div style="width:100%;">
	<table class="adminlist" width="100%">
	<?php 
	$task = JRequest::getVar('task');
	if ($task=='trans_viewbyuser')
	{
	?>
		<tr>
		
			<td width="100%" colspan="2" valign="top">
				<div style="width:100%;">
					<?php echo $this->menu();?>
				</div>
			</td>
		</tr>
	<?php
	}
	?>		
		<tr>
			<td align="left" width="100%">
				<?php echo JText::_( 'Filter name' ); ?>:
				<input type="text" name="search" id="search" value="<?php echo $this->lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
				<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
				<button onclick="document.getElementById('search').value='';document.getElementById('filter_status').value='';this.form.submit();"><?php echo JText::_( 'Filter Reset' ); ?></button>
			</td>		
			<td align="right">
				<?php
					echo $this->filter_status;
				?>
			</td>
		</tr>
	</table>
	<table class="adminlist" width="100%">
	<thead>
		<tr>
			<th width="5%">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $items);?>);" />
			</th>			
			<th class="sectiontableheader" width="5%">            		
    			<?php echo JHTML::_('grid.sort',   JText::_('ID'), 'a.id',@$this->lists['order_Dir'], @$this->lists['order']); ?>
    		</th>						
			<th class="sectiontableheader">            		
    			<?php echo JHTML::_('grid.sort',   JText::_('Customer'), 'b.name',@$this->lists['order_Dir'], @$this->lists['order']); ?>
    		</th> 
			<th class="sectiontableheader" width="15%">            		
    			<?php //echo JHTML::_('grid.sort',   JText::_('Products'), 'a.product_id',@$this->lists['order_Dir'], @$this->lists['order']); ?>
    			<?php echo JText::_('Products'); ?>
    		</th>    		
    		<th class="sectiontableheader" width="5%">            		
    			<?php echo JHTML::_('grid.sort',   JText::_('Amount')."(".$jbconfig['currency']->get('currency').")", 'a.amount',@$this->lists['order_Dir'], @$this->lists['order']); ?>
    		</th> 
 
			<th class="sectiontableheader" width="10%">            		
    			<?php echo JHTML::_('grid.sort',   JText::_('Payment Method'), 'a.payment_method',@$this->lists['order_Dir'], @$this->lists['order']); ?>
    		</th> 
			<th class="sectiontableheader" width="10%">            		
    			<?php echo JHTML::_('grid.sort',   JText::_('Receipt ID'), 'a.txn_id',@$this->lists['order_Dir'], @$this->lists['order']); ?>
    		</th>    		
			<th class="sectiontableheader" width="10%">            		
    			<?php //echo JHTML::_('grid.sort',   JText::_('Status'), 'a.completed',@$this->lists['order_Dir'], @$this->lists['order']); ?>
    			<?php echo JText::_('Status'); ?>
    		</th>      		
			<th class="sectiontableheader" width="10%">            		
    			<?php echo JHTML::_('grid.sort',   JText::_('Date created'), 'a.created_date',@$this->lists['order_Dir'], @$this->lists['order']); ?>
    		</th> 	
    		<th class="sectiontableheader" width="15%">            		
    			<?php echo JText::_('Action');?>
    		</th> 	
    	</tr>	
    </thead>
	<tfoot>
	<tr>
		<td colspan="13">
			<?php echo $pagination->getListFooter(); ?>
		</td>
	</tr>
	</tfoot>    
    <tbody>
    <?php
        for($i = 0, $n = count($items); $i < $n; $i++)
        {
        	$item = $items[$i];
        	$checked 	= JHTML::_('grid.id',   $i, $item->id );
       ?>
       		<tr class="row<?php echo $i%2; ?>">
       			<td width="5%" align="center">
       				<?php echo $checked; ?>
       			</td>
       			<td width="5%" align="center">
       			<?php
       				echo "<a href='index.php?option=$option&view=jatransactions&layout=trans_detail&task=$task&userid=$user_id&cid[]=$item->id' />";
       				echo $item->id; 
       				echo "</a>";
       			?>
       			</td>
       			<td align="left" width="15%">
       			<?php 
       			echo "<a href='index.php?option=$option&view=jaemployers&task=user&cid[]=$item->user_id' />";
       			echo $item->name ; 
       			?>
       			</td>
       			<td width="10%" align="left">
       				<?php echo $item->product_name?></td>
       			</td>       			
       			<td width="5%" align="center">
       			<?php echo $item->amount ; ?>
       			</td>

       			<td width="10%" align="left">
       				<?php echo $item->payment_name; ?>
       			</td>
       			<td width="10%" align="center">
       				<?php echo $item->txn_id?$item->txn_id:JText::_("N/A"); ?>
       			</td>
       			<td width="10%" align="center">
       				<?php echo JText::_($item->status_name);?>
       			</td>
       			<td width="10%" align="center">
       				<?php echo generateDate($item->created_date);?>
       			</td>
       			<td width="15%" align="center">
       	<?php
       				echo "<a href='index.php?option=$option&view=jatransactions&layout=view&task=$task&userid=$user_id&cid[]=$item->id' />";
       				echo JText::_('View invoice');
	       			echo "</a>";
	       			if ($item->completed)
	       				echo " / <a href='index.php?option=$option&view=jatransactions&layout=view&pre_task=$task&task=revert&product_type=$item->product_type&product_id=$item->product_id&userid=$item->user_id&cid[]=$item->id'>".JText::_('Reverse')."</a>";
	       			elseif($item->reason!='') echo ' / '.JText::_('Reversed');
       				?>
       			</td>       			
       		</tr>
       	<?php
        }
        ?>    
    </tbody>			
	</table>
</div>

<input type="hidden" name="filter_order" value="<?php echo $lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $lists['order_Dir']; ?>" />
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="old_limit" value="<?php echo $pagination->limit; ?>" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="view" value="jatransactions" />
<input type="hidden" name="pre_task" value="<?php echo $task; ?>" />
<input type="hidden" name="task" value="<?php echo $task; ?>" />
<input type="hidden" name="userid" value="<?php echo $user_id; ?>" />	
</form>